﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utilites;
using Business;
using System.Configuration;

namespace FileSharingHosting
{
    public partial class CreateAccount : System.Web.UI.Page
    {
        private int DefaultLastQuota = 5120;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void send_btn_Click(object sender, EventArgs e)
        {
            Validate();
            if (IsValid)
            {
                UsersBusinessLogic ubll = new UsersBusinessLogic();
                Entities.User user = new Entities.User();
                var user_role = ubll.GetRolesList().Single((role)=>(role.RoleLevel==Entities.UserPrivilegeLevels.User));

                MD5String passwd = password.Text;
                user.Login = login.Text;
                user.Password = passwd;
                user.Email = email.Text;
                user.LastQuota = DefaultLastQuota;
                user.Roles.Add(user_role);
                ubll.AddUser(user);
            }
        }
    }
}